package com.mayi.zds.provider;

import com.mayi.zds.entity.Goods;
import org.apache.ibatis.jdbc.SQL;

/**
 * 按条件查询用户
 */
public class GoodsProvider {
    /**
     * 按条件查询用户（姓名）
     * @param goods  条件的用户实例
     * @return  sql语句
     */
    public String getAllByCondition(Goods goods){
        return new SQL(){
            {
                SELECT("zds_goods.*").FROM("zds_goods,zds_goods_label").WHERE("zds_goods.id=zds_goods_label.goods_id");
                if(goods.getLabelId()!=null&&goods.getLabelId().trim().length()!=0){
                    WHERE("zds_goods_label.label_id=#{labelId}");
                }
            }
        }.toString();
    }
}
